package com.qzd.prototype.shallow;

import java.util.ArrayList;
import java.util.List;

/**
 * 浅克隆:克隆对象的引用值
 */
public class ConcretePrototy implements Cloneable {
    private String name;
    private int age;
    private List<String> slist=new ArrayList<String>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public List<String> getSlist() {
        return slist;
    }

    public void setSlist(List<String> slist) {
        this.slist = slist;
    }

    @Override
    public String toString() {
        return "ConcretePrototy{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", slist=" + slist +
                '}';
    }

    public ConcretePrototy clone() {
        try {
            return (ConcretePrototy) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
}
